import java.util.Arrays;

public class Work {
    public static int Max(int x, int y) {
        return (x > y) ? x : y;
    }

    public static double Max(double a, double b, double c) {
        double MaxAB = (a > b) ? a : b;
        return MaxAB > c ? MaxAB : c;
    }


    public static void main(String[] args) {
        int result = Max(10, 20);
        double result2 = Max(5.5, 6.6, 8.8);

        System.out.println(result);
        System.out.println(result2);
    }
}

class Work1 {
    public static int sum(int a, int b) {
        return a + b;
    }

    public static double sum(double a, double b, double c) {
        return a + b + c;
    }

    public static void main(String[] args) {

        int result = sum(1, 1);
        double result2 = sum(0.3, 0.2, 0.5);
        System.out.println("两个整数之和：" + result);
        System.out.println("三个小数之和：" + result2);
    }
}

class Bubblesort {
    public static void main(String[] args) {
        int[] arr = {24, 13, 80, 69, 57};

        for (int i = 0; i < arr.length; i++) {
            int temp = 0;
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}

class Haniotower {

    //输出从哪个柱子移动到哪根柱子
    public static void move(char a, char b) {
        System.out.print(a + " => " + b + " ");
    }

    /*
    num 是盘子的层数
    a,b,c 依次代表三根柱子
    * */
    public static void hanio(int num, char a, char b, char c) {
        if (num == 1) {
            move(a, c);
            return;
        }

        hanio(num - 1, a, c, b);
        //将num-1个盘子看成一个整体，通过c移动到b
        move(a, c);
        //将底层的盘子从a移动到c
        hanio(num - 1, b, a, c);
        //再通过a将num-1个盘子移动到c
    }

    public static void main(String[] args) {
        hanio(1, 'A', 'B', 'C');
        System.out.println();
        hanio(2, 'A', 'B', 'C');
        System.out.println();
        hanio(3, 'A', 'B', 'C');
        System.out.println();
    }

}

class Factorial {
    public static void main(String[] args) {
        int n = 5;
        int ret = factor(n);
        System.out.println(ret);
    }

    public static int factor(int n) {
        if (n == 1) {
            return 1;
        }
        return n * factor(n - 1);
    }
}

class Sum {
    public static void main(String[] args) {
        int num = 10;
        int ret = sum(num);
        System.out.println(ret);
    }

    public static int sum(int num) {
        if (num == 1) {
            return 1;
        }
        return num + sum(num - 1);

    }
}

class Work2 {
    public static void main(String[] args) {
        int num = 1729;
        int ret = sum(num);
        System.out.println(ret);

    }

    public static int sum(int num) {
        if (num == 1) {
            return 1;
        }
        return num % 10 + sum(num / 10);
    }
}

class Print {

    public static void print(int num) {
        if (num > 9) {
            print(num / 10);
        }
        System.out.print(num % 10 + " ");
    }

    public static void main(String[] args) {
        int num = 1234;
        print(num);
    }
}

class Fib {
    public static void main(String[] args) {
        System.out.print(fib(1) + " ");
        System.out.print(fib(2) + " ");
        System.out.print(fib(3) + " ");
        System.out.print(fib(4) + " ");
        System.out.print(fib(5) + " ");
        System.out.print(fib(6) + " ");


    }


    public static int fib1(int n) {
        if (n == 1 || n == 2) {
            return 1;
        }
        return fib1(n - 1) + fib1(n - 2);
    }

    public static int fib(int n) {
        if (n == 1 || n == 2) {
            return 1;
        }
        int f1 = 1;
        int f2 = 1;
        int f3 = 0;
        for (int i = 3; i <= n; i++) {
            f3 = f1 + f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }
}


class Array1 {

    public static double avg(int[] arr) {
        int sum = 0;
        for (int x : arr) {
            sum += x;
        }
        return sum / (double) arr.length;
    }

    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 3, 4, 5};
        System.out.println(avg(arr));
    }
}

class Array2 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6};
        System.out.println(sum(arr));
    }

    public static int sum(int[] arr) {
        int sum = 0;
        for (int x : arr) {
            sum += x;
        }
        return sum;
    }
}

class Array3 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3};
        transform(arr);
        for (int x : arr) {
            System.out.print(x + " ");
        }
    }

    public static void transform(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            arr[i] = arr[i] * 2;
        }
    }
}

class Array4 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6};
        printArray(arr);
    }

    public static void printArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}

class Array5 {
    public static void main(String[] args) {
        int[] arr = new int[101];
        for (int i = 1; i < arr.length; i++) {
            arr[i] = i;
            System.out.println(arr[i]);
        }
    }
}

class Array6 {
    public static void main(String[] args) {
        int[] arr1 = {1, 2, 3, 4, 5, 6};
        int[] arr2 = {2, 8, 1, 6, 7, 2};
        System.out.println(func(arr1));
        System.out.println(func(arr2));
    }

    public static boolean func(int[] arr) {

        if (arr.length <= 1) {
            return true;
        }

        for (int i = 0; i < arr.length - 1; i++) {
            if (arr[i] > arr[i + 1]) {
                return false;
            }
        }
        return true;

    }
}

class Array7 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        System.out.println(find(arr, 5));
    }

    public static int find(int[] arr, int toFind) {
        int left = 0;
        int right = arr.length - 1;


        while (left <= right) {
            int mid = (left + right) / 2;
            if (toFind < arr[mid]) {
                right = mid - 1;
            } else if (toFind > arr[mid]) {
                left = mid + 1;
            } else {
                return mid;
            }
        }
        return -1;
    }

}

class Array8 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        System.out.println(toString(arr));

    }

    public static String toString(int[] arr) {
        String ret = "[";
        for (int i = 0; i < arr.length; i++) {
            ret += arr[i];
            if (i < arr.length - 1) {
                ret += ", ";
            }
        }
        ret += "]";
        return ret;
    }
}


class Array9 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        int[] copy = copyOf(arr);
        System.out.println(Arrays.toString(copy));
        int[] copy2 = Arrays.copyOf(arr, 3);
        System.out.println(Arrays.toString(copy2));
    }

    public static int[] copyOf(int[] arr) {
        int[] newArr = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            newArr[i] = arr[i];
        }
        return newArr;
    }
}

class Array10 {
    public static void main(String[] args) {
        int[] arr = {10, 60, 78, 9};
        func(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void func(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            boolean flag = false;
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                    flag = true;
                }
            }
            if (flag == false) {
                break;
            }
        }
    }
}